﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using Domain.Entity.Dtos;
using SqlSugar;

namespace Domain.Entity.Entities
{
    [AutoMap(typeof(UserDto))]
    [SugarTable("sys_user")]
    public record User
    {
        [SugarColumn(IsPrimaryKey = true)]
        public int Id { get; private set; }

        public string Name { get; private set; }

        public string Email { get; private set; }

        public string Password { get; private set; }

        public static User CreateUser(string name, string email, string password)
        {
            return new User
            {
                Name = name,
                Email = email,
                Password = password
            };
        }

        public void UpdateUserName(string name)
        {
            Name = name;
        }

        public void UpdateUserEmail(string email)
        {
            Email = email;
        }

        public void UpdateUserPassword(string password)
        {
            Password = password;
        }

        public bool CheckUserPassword(string password)
        {
            if (Password != password)
            {
                return false;
            }
            return true;
        }
    }
}
